<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>父组件与子组件传值</title>
  </head>
  <body>
    <pre></pre>
    <div class="box">
      <hello :data-msg="value"></hello>
      <button>单击</button>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
      //自定义组件  子组件
      Vue.component('hello', {
        props: ['dataMsg'],
        data: function () {
          return {
            msg: 'hello',
          }
        },
        template: `
        <div>
            <div>{{msg}} </div>
            <div>{{dataMsg}}
            <button @click="get">单击</button>
            </div>
        </div>
        `,
        methods: {
          get() {
            console.log(typeof this.dataMsg)
          },
        },
      })

      new Vue({
        el: '.box',
        data: {
          value: 123,
        },
        methods: {},
      })
    </script>
  </body>
</html>
